<?php 
namespace App\Http\Controllers\Admin;


use Validator;
use App\Http\Requests;
use App\Http\Controllers\Controller;
use Illuminate\Foundation\Admin\ThrottlesLogins;
use Illuminate\Foundation\Admin\AuthenticatesAndRegistersUsers;
use Request;
class MemberController extends Controller{
	//会员列表
	public function member_list(){
		$member = new \App\Member();
		$list = $member->select();
		return view("Admin/member/member_list",["member_list"=>$list]);
	}
	//会员编辑
	public function member_up($user_id){
		$req = request();
		$member = new \App\Member();
		if($_POST){
			if($_POST["user_password"] != $_POST["que_password"]){
				echo '<script>alert("两次密码输入不一致！");window.location.href="member_up";</script>';
			}else{
				$data = array(
	              'user_name'=>$req->user_name,
	              'user_tel'=>$req->user_tel,
	              'user_password'=>md5($req->user_password),
	              'user_email'=>$req->user_email
	          	);
	            $res = $member->lists_up($data,$user_id);
	            if($res == 0){
	                echo '<script>alert("修改轮播图失败");window.location.href="member_up";</script>';
	            }else{
	                return redirect('/admin/member_list');
	            }
			}
		}else{
			$res = $member->getOne($user_id);
			return view("Admin/member/member_up",["res"=>$res]);
		}
	}
	//会员删除
	public function member_del($user_id){
		$member = new \App\Member();
		$is_show = $member->getOne($user_id);
		if($is_show->is_show == 0){
			$data = ['is_show'=>1];
		}else{
			$data = ['is_show'=>0];
		}
        $res = $member->del($user_id,$data);
        var_dump($res);
        if($res != 0){
        	return redirect('/admin/member_list');
        }
	}
}